From 57bcfa11b151fdbb71c256fa47592fc6a535c487 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 4 Nov 2008 12:13:42 +0000 Subject: [PATCH] tools/hotplug: Separate OS-specific scripts. Signed-off-by: Christoph Egger Signed-off-by: Keir Fraser --- tools/Makefile | 1 + tools/examples/Makefile | 58 +---------- tools/hotplug/Linux/Makefile | 97 +++++++++++++++++++ tools/{examples => hotplug/Linux}/blktap | 0 tools/{examples => hotplug/Linux}/block | 0 .../Linux}/block-common.sh | 0 tools/{examples => hotplug/Linux}/block-enbd | 0 tools/{examples => hotplug/Linux}/block-nbd | 0 .../Linux}/external-device-migrate | 0 .../Linux}/init.d/sysconfig.xendomains | 0 tools/{examples => hotplug/Linux}/init.d/xend | 0 .../Linux}/init.d/xendomains | 0 tools/{examples => hotplug/Linux}/locking.sh | 0 tools/{examples => hotplug/Linux}/logging.sh | 0 .../Linux}/network-bridge | 0 tools/{examples => hotplug/Linux}/network-nat | 0 .../{examples => hotplug/Linux}/network-route | 0 tools/{examples => hotplug/Linux}/vif-bridge | 0 .../{examples => hotplug/Linux}/vif-common.sh | 0 tools/{examples => hotplug/Linux}/vif-nat | 0 tools/{examples => hotplug/Linux}/vif-route | 0 tools/{examples => hotplug/Linux}/vscsi | 0 tools/{examples => hotplug/Linux}/vtpm | 0 .../Linux}/vtpm-common.sh | 0 tools/{examples => hotplug/Linux}/vtpm-delete | 0 .../Linux}/vtpm-hotplug-common.sh | 0 tools/{examples => hotplug/Linux}/vtpm-impl | 0 .../Linux}/vtpm-migration.sh | 0 .../Linux}/xen-backend.agent | 0 .../Linux}/xen-backend.rules | 0 .../Linux}/xen-hotplug-cleanup | 0 .../Linux}/xen-hotplug-common.sh | 0 .../Linux}/xen-network-common.sh | 0 .../Linux}/xen-script-common.sh | 0 tools/hotplug/Makefile | 9 ++ tools/hotplug/NetBSD/Makefile | 41 ++++++++ tools/hotplug/NetBSD/block-nbsd | 88 +++++++++++++++++ tools/hotplug/NetBSD/qemu-ifup-nbsd | 3 + tools/hotplug/NetBSD/vif-bridge-nbsd | 35 +++++++ tools/hotplug/NetBSD/vif-ip-nbsd | 33 +++++++ tools/hotplug/common/Makefile | 37 +++++++ 41 files changed, 345 insertions(+), 57 deletions(-) create mode 100644 tools/hotplug/Linux/Makefile rename tools/{examples => hotplug/Linux}/blktap (100%) rename tools/{examples => hotplug/Linux}/block (100%) rename tools/{examples => hotplug/Linux}/block-common.sh (100%) rename tools/{examples => hotplug/Linux}/block-enbd (100%) mode change 100755 => 100644 rename tools/{examples => hotplug/Linux}/block-nbd (100%) rename tools/{examples => hotplug/Linux}/external-device-migrate (100%) rename tools/{examples => hotplug/Linux}/init.d/sysconfig.xendomains (100%) rename tools/{examples => hotplug/Linux}/init.d/xend (100%) rename tools/{examples => hotplug/Linux}/init.d/xendomains (100%) rename tools/{examples => hotplug/Linux}/locking.sh (100%) rename tools/{examples => hotplug/Linux}/logging.sh (100%) rename tools/{examples => hotplug/Linux}/network-bridge (100%) mode change 100755 => 100644 rename tools/{examples => hotplug/Linux}/network-nat (100%) rename tools/{examples => hotplug/Linux}/network-route (100%) mode change 100755 => 100644 rename tools/{examples => hotplug/Linux}/vif-bridge (100%) mode change 100755 => 100644 rename tools/{examples => hotplug/Linux}/vif-common.sh (100%) rename tools/{examples => hotplug/Linux}/vif-nat (100%) rename tools/{examples => hotplug/Linux}/vif-route (100%) mode change 100755 => 100644 rename tools/{examples => hotplug/Linux}/vscsi (100%) rename tools/{examples => hotplug/Linux}/vtpm (100%) rename tools/{examples => hotplug/Linux}/vtpm-common.sh (100%) rename tools/{examples => hotplug/Linux}/vtpm-delete (100%) rename tools/{examples => hotplug/Linux}/vtpm-hotplug-common.sh (100%) rename tools/{examples => hotplug/Linux}/vtpm-impl (100%) rename tools/{examples => hotplug/Linux}/vtpm-migration.sh (100%) rename tools/{examples => hotplug/Linux}/xen-backend.agent (100%) mode change 100755 => 100644 rename tools/{examples => hotplug/Linux}/xen-backend.rules (100%) rename tools/{examples => hotplug/Linux}/xen-hotplug-cleanup (100%) rename tools/{examples => hotplug/Linux}/xen-hotplug-common.sh (100%) rename tools/{examples => hotplug/Linux}/xen-network-common.sh (100%) rename tools/{examples => hotplug/Linux}/xen-script-common.sh (100%) create mode 100644 tools/hotplug/Makefile create mode 100644 tools/hotplug/NetBSD/Makefile create mode 100644 tools/hotplug/NetBSD/block-nbsd create mode 100644 tools/hotplug/NetBSD/qemu-ifup-nbsd create mode 100644 tools/hotplug/NetBSD/vif-bridge-nbsd create mode 100644 tools/hotplug/NetBSD/vif-ip-nbsd create mode 100644 tools/hotplug/common/Makefile diff --git a/tools/Makefile b/tools/Makefile index 09964323e9..0d872b6fa4 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -9,6 +9,7 @@ SUBDIRS-y += flask SUBDIRS-y += xenstore SUBDIRS-y += misc SUBDIRS-y += examples +SUBDIRS-y += hotplug SUBDIRS-y += xentrace SUBDIRS-$(CONFIG_XCUTILS) += xcutils SUBDIRS-$(CONFIG_X86) += firmware diff --git a/tools/examples/Makefile b/tools/examples/Makefile index 39310394f5..6c8349b154 100644 --- a/tools/examples/Makefile +++ b/tools/examples/Makefile @@ -24,41 +24,6 @@ XEN_CONFIGS += xmexample.vti XEN_CONFIGS += xend-pci-quirks.sxp XEN_CONFIGS += xend-pci-permissive.sxp -# Xen script dir and scripts to go there. -XEN_SCRIPT_DIR = /etc/xen/scripts -XEN_SCRIPTS = network-bridge vif-bridge -XEN_SCRIPTS += network-route vif-route -XEN_SCRIPTS += network-nat vif-nat -XEN_SCRIPTS += block -XEN_SCRIPTS += block-enbd block-nbd -XEN_SCRIPTS += blktap -XEN_SCRIPTS += vtpm vtpm-delete -XEN_SCRIPTS += xen-hotplug-cleanup -XEN_SCRIPTS += external-device-migrate -XEN_SCRIPTS += vscsi -XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh -XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh -XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh vtpm-hotplug-common.sh -XEN_SCRIPT_DATA += vtpm-migration.sh vtpm-impl - -XEN_HOTPLUG_DIR = /etc/hotplug -XEN_HOTPLUG_SCRIPTS = xen-backend.agent - -UDEV_RULES_DIR = /etc/udev -UDEV_RULES = xen-backend.rules - -DI = $(if $(DISTDIR),$(shell readlink -f $(DISTDIR)),) -DE = $(if $(DESTDIR),$(shell readlink -f $(DESTDIR)),) -ifeq ($(findstring $(DI),$(DE)),$(DI)) -HOTPLUGS=install-hotplug install-udev -else -ifeq ($(shell [ -x /usr/bin/udevinfo ] && [ `/usr/bin/udevinfo -V | sed -e 's/^[^0-9]* \([0-9]\{1,\}\)[^0-9]\{0,\}/\1/'` -ge 059 ] && echo 1),1) -HOTPLUGS=install-udev -else -HOTPLUGS=install-hotplug -endif -endif - .PHONY: all all: @@ -66,7 +31,7 @@ all: build: .PHONY: install -install: all install-readmes install-initd install-configs install-scripts $(HOTPLUGS) +install: all install-readmes install-configs $(HOTPLUGS) .PHONY: install-readmes install-readmes: @@ -77,14 +42,6 @@ install-readmes: $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_CONFIG_DIR); \ done -.PHONY: install-initd -install-initd: - [ -d $(DESTDIR)/etc/init.d ] || $(INSTALL_DIR) $(DESTDIR)/etc/init.d - [ -d $(DESTDIR)/etc/sysconfig ] || $(INSTALL_DIR) $(DESTDIR)/etc/sysconfig - $(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)/etc/init.d - $(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)/etc/init.d - $(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)/etc/sysconfig/xendomains - .PHONY: install-configs install-configs: $(XEN_CONFIGS) [ -d $(DESTDIR)$(XEN_CONFIG_DIR) ] || \ @@ -96,19 +53,6 @@ install-configs: $(XEN_CONFIGS) $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_CONFIG_DIR); \ done -.PHONY: install-scripts -install-scripts: - [ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \ - $(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR) - set -e; for i in $(XEN_SCRIPTS); \ - do \ - $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \ - done - set -e; for i in $(XEN_SCRIPT_DATA); \ - do \ - $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \ - done - .PHONY: install-hotplug install-hotplug: [ -d $(DESTDIR)$(XEN_HOTPLUG_DIR) ] || \ diff --git a/tools/hotplug/Linux/Makefile b/tools/hotplug/Linux/Makefile new file mode 100644 index 0000000000..19ba78ffdb --- /dev/null +++ b/tools/hotplug/Linux/Makefile @@ -0,0 +1,97 @@ +XEN_ROOT = ../../../ +include $(XEN_ROOT)/tools/Rules.mk + +# Init scripts. +XEND_INITD = init.d/xend +XENDOMAINS_INITD = init.d/xendomains +XENDOMAINS_SYSCONFIG = init.d/sysconfig.xendomains + +# Xen configuration dir and configs to go there. +XEN_CONFIG_DIR = /etc/xen + +# Xen script dir and scripts to go there. +XEN_SCRIPT_DIR = /etc/xen/scripts +XEN_SCRIPTS = network-bridge vif-bridge +XEN_SCRIPTS += network-route vif-route +XEN_SCRIPTS += network-nat vif-nat +XEN_SCRIPTS += block +XEN_SCRIPTS += block-enbd block-nbd +XEN_SCRIPTS += blktap +XEN_SCRIPTS += vtpm vtpm-delete +XEN_SCRIPTS += xen-hotplug-cleanup +XEN_SCRIPTS += external-device-migrate +XEN_SCRIPTS += vscsi +XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh +XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh +XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh vtpm-hotplug-common.sh +XEN_SCRIPT_DATA += vtpm-migration.sh vtpm-impl + +XEN_HOTPLUG_DIR = /etc/hotplug +XEN_HOTPLUG_SCRIPTS = xen-backend.agent + +UDEV_RULES_DIR = /etc/udev +UDEV_RULES = xen-backend.rules + +DI = $(if $(DISTDIR),$(shell readlink -f $(DISTDIR)),) +DE = $(if $(DESTDIR),$(shell readlink -f $(DESTDIR)),) +ifeq ($(findstring $(DI),$(DE)),$(DI)) +HOTPLUGS=install-hotplug install-udev +else +ifeq ($(shell [ -x /usr/bin/udevinfo ] && [ `/usr/bin/udevinfo -V | sed -e 's/^[^0-9]* \([0-9]\{1,\}\)[^0-9]\{0,\}/\1/'` -ge 059 ] && echo 1),1) +HOTPLUGS=install-udev +else +HOTPLUGS=install-hotplug +endif +endif + +.PHONY: all +all: + +.PHONY: build +build: + +.PHONY: install +install: all install-initd install-scripts $(HOTPLUGS) + +.PHONY: install-initd +install-initd: + [ -d $(DESTDIR)/etc/init.d ] || $(INSTALL_DIR) $(DESTDIR)/etc/init.d + [ -d $(DESTDIR)/etc/sysconfig ] || $(INSTALL_DIR) $(DESTDIR)/etc/sysconfig + $(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)/etc/init.d + $(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)/etc/init.d + $(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)/etc/sysconfig/xendomains + +.PHONY: install-scripts +install-scripts: + [ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \ + $(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR) + set -e; for i in $(XEN_SCRIPTS); \ + do \ + $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \ + done + set -e; for i in $(XEN_SCRIPT_DATA); \ + do \ + $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \ + done + +.PHONY: install-hotplug +install-hotplug: + [ -d $(DESTDIR)$(XEN_HOTPLUG_DIR) ] || \ + $(INSTALL_DIR) $(DESTDIR)$(XEN_HOTPLUG_DIR) + set -e; for i in $(XEN_HOTPLUG_SCRIPTS); \ + do \ + $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_HOTPLUG_DIR); \ + done + +.PHONY: install-udev +install-udev: + [ -d $(DESTDIR)$(UDEV_RULES_DIR) ] || \ + $(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)/rules.d + set -e; for i in $(UDEV_RULES); \ + do \ + $(INSTALL_DATA) $$i $(DESTDIR)$(UDEV_RULES_DIR); \ + ln -sf ../$$i $(DESTDIR)$(UDEV_RULES_DIR)/rules.d; \ + done + +.PHONY: clean +clean: diff --git a/tools/examples/blktap b/tools/hotplug/Linux/blktap similarity index 100% rename from tools/examples/blktap rename to tools/hotplug/Linux/blktap diff --git a/tools/examples/block b/tools/hotplug/Linux/block similarity index 100% rename from tools/examples/block rename to tools/hotplug/Linux/block diff --git a/tools/examples/block-common.sh b/tools/hotplug/Linux/block-common.sh similarity index 100% rename from tools/examples/block-common.sh rename to tools/hotplug/Linux/block-common.sh diff --git a/tools/examples/block-enbd b/tools/hotplug/Linux/block-enbd old mode 100755 new mode 100644 similarity index 100% rename from tools/examples/block-enbd rename to tools/hotplug/Linux/block-enbd diff --git a/tools/examples/block-nbd b/tools/hotplug/Linux/block-nbd similarity index 100% rename from tools/examples/block-nbd rename to tools/hotplug/Linux/block-nbd diff --git a/tools/examples/external-device-migrate b/tools/hotplug/Linux/external-device-migrate similarity index 100% rename from tools/examples/external-device-migrate rename to tools/hotplug/Linux/external-device-migrate diff --git a/tools/examples/init.d/sysconfig.xendomains b/tools/hotplug/Linux/init.d/sysconfig.xendomains similarity index 100% rename from tools/examples/init.d/sysconfig.xendomains rename to tools/hotplug/Linux/init.d/sysconfig.xendomains diff --git a/tools/examples/init.d/xend b/tools/hotplug/Linux/init.d/xend similarity index 100% rename from tools/examples/init.d/xend rename to tools/hotplug/Linux/init.d/xend diff --git a/tools/examples/init.d/xendomains b/tools/hotplug/Linux/init.d/xendomains similarity index 100% rename from tools/examples/init.d/xendomains rename to tools/hotplug/Linux/init.d/xendomains diff --git a/tools/examples/locking.sh b/tools/hotplug/Linux/locking.sh similarity index 100% rename from tools/examples/locking.sh rename to tools/hotplug/Linux/locking.sh diff --git a/tools/examples/logging.sh b/tools/hotplug/Linux/logging.sh similarity index 100% rename from tools/examples/logging.sh rename to tools/hotplug/Linux/logging.sh diff --git a/tools/examples/network-bridge b/tools/hotplug/Linux/network-bridge old mode 100755 new mode 100644 similarity index 100% rename from tools/examples/network-bridge rename to tools/hotplug/Linux/network-bridge diff --git a/tools/examples/network-nat b/tools/hotplug/Linux/network-nat similarity index 100% rename from tools/examples/network-nat rename to tools/hotplug/Linux/network-nat diff --git a/tools/examples/network-route b/tools/hotplug/Linux/network-route old mode 100755 new mode 100644 similarity index 100% rename from tools/examples/network-route rename to tools/hotplug/Linux/network-route diff --git a/tools/examples/vif-bridge b/tools/hotplug/Linux/vif-bridge old mode 100755 new mode 100644 similarity index 100% rename from tools/examples/vif-bridge rename to tools/hotplug/Linux/vif-bridge diff --git a/tools/examples/vif-common.sh b/tools/hotplug/Linux/vif-common.sh similarity index 100% rename from tools/examples/vif-common.sh rename to tools/hotplug/Linux/vif-common.sh diff --git a/tools/examples/vif-nat b/tools/hotplug/Linux/vif-nat similarity index 100% rename from tools/examples/vif-nat rename to tools/hotplug/Linux/vif-nat diff --git a/tools/examples/vif-route b/tools/hotplug/Linux/vif-route old mode 100755 new mode 100644 similarity index 100% rename from tools/examples/vif-route rename to tools/hotplug/Linux/vif-route diff --git a/tools/examples/vscsi b/tools/hotplug/Linux/vscsi similarity index 100% rename from tools/examples/vscsi rename to tools/hotplug/Linux/vscsi diff --git a/tools/examples/vtpm b/tools/hotplug/Linux/vtpm similarity index 100% rename from tools/examples/vtpm rename to tools/hotplug/Linux/vtpm diff --git a/tools/examples/vtpm-common.sh b/tools/hotplug/Linux/vtpm-common.sh similarity index 100% rename from tools/examples/vtpm-common.sh rename to tools/hotplug/Linux/vtpm-common.sh diff --git a/tools/examples/vtpm-delete b/tools/hotplug/Linux/vtpm-delete similarity index 100% rename from tools/examples/vtpm-delete rename to tools/hotplug/Linux/vtpm-delete diff --git a/tools/examples/vtpm-hotplug-common.sh b/tools/hotplug/Linux/vtpm-hotplug-common.sh similarity index 100% rename from tools/examples/vtpm-hotplug-common.sh rename to tools/hotplug/Linux/vtpm-hotplug-common.sh diff --git a/tools/examples/vtpm-impl b/tools/hotplug/Linux/vtpm-impl similarity index 100% rename from tools/examples/vtpm-impl rename to tools/hotplug/Linux/vtpm-impl diff --git a/tools/examples/vtpm-migration.sh b/tools/hotplug/Linux/vtpm-migration.sh similarity index 100% rename from tools/examples/vtpm-migration.sh rename to tools/hotplug/Linux/vtpm-migration.sh diff --git a/tools/examples/xen-backend.agent b/tools/hotplug/Linux/xen-backend.agent old mode 100755 new mode 100644 similarity index 100% rename from tools/examples/xen-backend.agent rename to tools/hotplug/Linux/xen-backend.agent diff --git a/tools/examples/xen-backend.rules b/tools/hotplug/Linux/xen-backend.rules similarity index 100% rename from tools/examples/xen-backend.rules rename to tools/hotplug/Linux/xen-backend.rules diff --git a/tools/examples/xen-hotplug-cleanup b/tools/hotplug/Linux/xen-hotplug-cleanup similarity index 100% rename from tools/examples/xen-hotplug-cleanup rename to tools/hotplug/Linux/xen-hotplug-cleanup diff --git a/tools/examples/xen-hotplug-common.sh b/tools/hotplug/Linux/xen-hotplug-common.sh similarity index 100% rename from tools/examples/xen-hotplug-common.sh rename to tools/hotplug/Linux/xen-hotplug-common.sh diff --git a/tools/examples/xen-network-common.sh b/tools/hotplug/Linux/xen-network-common.sh similarity index 100% rename from tools/examples/xen-network-common.sh rename to tools/hotplug/Linux/xen-network-common.sh diff --git a/tools/examples/xen-script-common.sh b/tools/hotplug/Linux/xen-script-common.sh similarity index 100% rename from tools/examples/xen-script-common.sh rename to tools/hotplug/Linux/xen-script-common.sh diff --git a/tools/hotplug/Makefile b/tools/hotplug/Makefile new file mode 100644 index 0000000000..979e916d7f --- /dev/null +++ b/tools/hotplug/Makefile @@ -0,0 +1,9 @@ +XEN_ROOT = ../../ +include $(XEN_ROOT)/tools/Rules.mk + +SUBDIRS-y := common +SUBDIRS-$(CONFIG_NetBSD) += NetBSD +SUBDIRS-$(CONFIG_Linux) += Linux + +.PHONY: all clean install +all clean install: %: subdirs-% diff --git a/tools/hotplug/NetBSD/Makefile b/tools/hotplug/NetBSD/Makefile new file mode 100644 index 0000000000..1d369eaf9a --- /dev/null +++ b/tools/hotplug/NetBSD/Makefile @@ -0,0 +1,41 @@ +XEN_ROOT = ../../../ +include $(XEN_ROOT)/tools/Rules.mk + +# Xen configuration dir and configs to go there. +XEN_CONFIG_DIR = $(PREFIX)/etc/xen + +# Xen script dir and scripts to go there. +XEN_SCRIPT_DIR = $(PREFIX)/etc/xen/scripts +XEN_SCRIPTS = +XEN_SCRIPTS += block-nbsd +XEN_SCRIPTS += hvm-nbsd +XEN_SCRIPTS += netbsd1-nbsd +XEN_SCRIPTS += qemu-ifup-nbsd +XEN_SCRIPTS += vif-bridge-nbsd +XEN_SCRIPTS += vif-ip-nbsd + +XEN_SCRIPT_DATA = + +.PHONY: all +all: + +.PHONY: build +build: + +.PHONY: install +install: all install-scripts + +.PHONY: install-scripts +install-scripts: + $(INSTALL_DATA_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR) + set -e; for i in $(XEN_SCRIPTS); \ + do \ + $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \ + done + set -e; for i in $(XEN_SCRIPT_DATA); \ + do \ + $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \ + done + +.PHONY: clean +clean: diff --git a/tools/hotplug/NetBSD/block-nbsd b/tools/hotplug/NetBSD/block-nbsd new file mode 100644 index 0000000000..915ddb755a --- /dev/null +++ b/tools/hotplug/NetBSD/block-nbsd @@ -0,0 +1,88 @@ +#!/bin/sh -e + +# $NetBSD: block-nbsd,v 1.1.1.1 2008/08/07 20:26:57 cegger Exp $ +# Called by xenbackendd +# Usage: block xsdir_backend_path state + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +export PATH + +error() { + echo "$@" >&2 + xenstore_write $xpath/hotplug-status error + exit 1 +} + + +xpath=$1 +xstatus=$2 +xtype=$(xenstore-read "$xpath/type") +xparams=$(xenstore-read "$xpath/params") + +case $xstatus in +6) + # device removed + case $xtype in + file) + vnd=$(xenstore-read "$xpath/vnd" || echo none) + if [ $vnd != none ]; then + vnconfig -u $vnd + fi + ;; + phy) + ;; + *) + echo "unknown type $xtype" >&2 + ;; + esac + xenstore-rm $xpath + exit 0 + ;; +2) + case $xtype in + file) + # Store the list of available vnd(4) devices in + #``available_disks'', and mark them as ``free''. + list=`ls -1 /dev/vnd[0-9]*d | sed "s,/dev/vnd,,;s,d,," | sort -n` + for i in $list; do + disk="vnd$i" + available_disks="$available_disks $disk" + eval $disk=free + done + # Mark the used vnd(4) devices as ``used''. + for disk in `sysctl hw.disknames`; do + case $disk in + vnd[0-9]*) eval $disk=used ;; + esac + done + # Configure the first free vnd(4) device. + for disk in $available_disks; do + eval status=\$$disk + if [ "$status" = "free" ] && \ + vnconfig /dev/${disk}d $xparams >/dev/null; then + device=/dev/${disk}d + echo vnconfig /dev/${disk}d $xparams + break + fi + done + if [ x$device = x ] ; then + error "no available vnd device" + fi + echo xenstore-write $xpath/vnd $device + xenstore-write $xpath/vnd $device + ;; + phy) + device=$xparams + ;; + esac + physical_device=$(stat -f '%r' "$device") + echo xenstore-write $xpath/physical-device $physical_device + xenstore-write $xpath/physical-device $physical_device + echo xenstore-write $xpath/hotplug-status connected + xenstore-write $xpath/hotplug-status connected + exit 0 + ;; +*) + exit 0 + ;; +esac diff --git a/tools/hotplug/NetBSD/qemu-ifup-nbsd b/tools/hotplug/NetBSD/qemu-ifup-nbsd new file mode 100644 index 0000000000..eee78765d6 --- /dev/null +++ b/tools/hotplug/NetBSD/qemu-ifup-nbsd @@ -0,0 +1,3 @@ +#!/bin/sh +ifconfig $1 up +exec /sbin/brconfig $2 add $1 diff --git a/tools/hotplug/NetBSD/vif-bridge-nbsd b/tools/hotplug/NetBSD/vif-bridge-nbsd new file mode 100644 index 0000000000..bedb387953 --- /dev/null +++ b/tools/hotplug/NetBSD/vif-bridge-nbsd @@ -0,0 +1,35 @@ +#!/bin/sh -e + +# $NetBSD: vif-bridge-nbsd,v 1.1.1.1 2008/08/07 20:26:57 cegger Exp $ +# Called by xenbackendd +# Usage: vif-bridge xsdir_backend_path state + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +export PATH + +xpath=$1 +xstatus=$2 + +case $xstatus in +6) + # device removed + xenstore-rm $xpath + exit 0 + ;; +2) + xbridge=$(xenstore-read "$xpath/bridge") + xfid=$(xenstore-read "$xpath/frontend-id") + xhandle=$(xenstore-read "$xpath/handle") + iface=xvif$xfid.$xhandle + echo ifconfig $iface up + ifconfig $iface up + brconfig $xbridge add $iface + echo brconfig $xbridge add $iface + xenstore-write $xpath/hotplug-status connected + echo xenstore-write $xpath/hotplug-status connected + exit 0 + ;; +*) + exit 0 + ;; +esac diff --git a/tools/hotplug/NetBSD/vif-ip-nbsd b/tools/hotplug/NetBSD/vif-ip-nbsd new file mode 100644 index 0000000000..d8b5bb9759 --- /dev/null +++ b/tools/hotplug/NetBSD/vif-ip-nbsd @@ -0,0 +1,33 @@ +#!/bin/sh -e + +# $NetBSD: vif-ip-nbsd,v 1.1.1.1 2008/08/07 20:26:57 cegger Exp $ +# Called by xenbackendd +# Usage: vif-ip xsdir_backend_path state + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +export PATH + +xpath=$1 +xstatus=$2 + +case $xstatus in +6) + # device removed + xenstore-rm $xpath + exit 0 + ;; +2) + xip=$(xenstore-read "$xpath/ip") + xfid=$(xenstore-read "$xpath/frontend-id") + xhandle=$(xenstore-read "$xpath/handle") + iface=xvif$xfid.$xhandle + echo ifconfig $iface $xip up + ifconfig $iface $xip up + xenstore-write $xpath/hotplug-status connected + echo xenstore-write $xpath/hotplug-status connected + exit 0 + ;; +*) + exit 0 + ;; +esac diff --git a/tools/hotplug/common/Makefile b/tools/hotplug/common/Makefile new file mode 100644 index 0000000000..b69b9991af --- /dev/null +++ b/tools/hotplug/common/Makefile @@ -0,0 +1,37 @@ +XEN_ROOT = ../../../ +include $(XEN_ROOT)/tools/Rules.mk + +# OS-independent hotplug scripts go in this directory + +# Xen configuration dir and configs to go there. +XEN_CONFIG_DIR = /etc/xen + +# Xen script dir and scripts to go there. +XEN_SCRIPT_DIR = /etc/xen/scripts +XEN_SCRIPTS = +XEN_SCRIPT_DATA = + +.PHONY: all +all: + +.PHONY: build +build: + +.PHONY: install +install: all install-scripts + +.PHONY: install-scripts +install-scripts: + [ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \ + $(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR) + set -e; for i in $(XEN_SCRIPTS); \ + do \ + $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \ + done + set -e; for i in $(XEN_SCRIPT_DATA); \ + do \ + $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \ + done + +.PHONY: clean +clean: -- 2.30.2